/**
 * fulihui.com Inc.
 * Copyright (c) 2015-2016 All Rights Reserved.
 */
package com.fulihui.usercore.utils;

import com.fulihui.usercore.core.processor.vcode.VcodeProcessor;
import com.fulihui.usercore.core.processor.vcode.VcodeProcessorRegistor;
import com.fulihui.usercore.enums.VcodeProcessTypeEnum;
import com.fulihui.usercore.request.vcode.VcodeCheckRequest;
import org.near.servicesupport.request.RequestBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zhangyingjie
 * @version $Id: v 0.1 2017年05月24日 14:55 zhangyingjie Exp $
 */
@Component
public class CheckSmsCodeUtil {
    @Autowired
    private VcodeProcessorRegistor vcodeProcessorRegistor;
    /**
     * 验证短息验证码
     * @param loginId 登陆账号
     * @param smsCode 短信验证码
     * @param namespace 命名空间
     * @return 验证结果 true/false
     */
   public boolean checkSmsCode(String loginId, String smsCode, String namespace) {
        VcodeCheckRequest vcodeCheckRequest = RequestBuilder.build(VcodeCheckRequest.class);
        vcodeCheckRequest.setAccountNo(loginId);
        vcodeCheckRequest.setVcode(smsCode);
        vcodeCheckRequest.setVcodeNamespace(namespace);
        VcodeProcessor processor = vcodeProcessorRegistor.getProcessor(VcodeProcessTypeEnum.MOBILE_SMS);
        return processor.check(vcodeCheckRequest);
    }
}
